Skip to content

UI must be created before first render, drainMicroTasks when the first page is created #1103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 6, 2017

Conversation

PanayotCankov
Copy link
Contributor

Removes the white screen displayed between the launch screen and the initial page view.
Speeds up roughly 300ms startup times for iOS with Angular.

It turns out the UI that is created on viewWillAppear is just a blank Page (we knew that!)
But then few promises resolve leading to the router navigation and building the actual page UI,
these promises are resolved on the main loop, so the iOS have the time to pass a Window layout and render the blank page.

Then, the interesting part, the iOS framework will not run a second layout immediately but will play the intro animation completely, (having 300ms idle time here) and after that run Window layout. In the SDK examples the ListView will start realising cells on that second layout pass and will consume roughly 250ms.

Draining the micro tasks in viewWillAppear will let Angular apps create the UI before the native have a chance to draw a blank screen and will not experience the 300ms. idle delay on startup.

IT IS AWESOME!!!

Now:

  1. The Angular apps for iOS are nearly as fast as vanilla.
  2. We have to figure out the best way to handle this, if we manage to make angular boot synchronously instead of draining the micro tasks it would be better. Draining the micro tasks may have side effects as executing client code (such as setImmediate, setTimeout and then-ing resolved promises) out of order.

@ghost ghost assigned PanayotCankov Nov 30, 2017
@ghost ghost added the in progress label Nov 30, 2017
@PanayotCankov PanayotCankov force-pushed the drain-task-on-start branch 2 times, most recently from 28f5496 to b15cf00 Compare November 30, 2017 07:47
@PanayotCankov
Copy link
Contributor Author

Btw we should now re-measure the angular overhead on {N} apps, it may turn out it is not as much as we thought it was.

Copy link
Contributor

@vakrilov vakrilov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make a separate PR with the zone.js patches in:
https://github.com/NativeScript/zone.js -> zone-nativescript branch.

We use this guide to build dist versions of the zone - so it is important to have the patches in the zone repo so they are not lost next time we update the zone.

@PanayotCankov
Copy link
Contributor Author

Done the zone.js repo: NativeScript/zone.js@fcca557

@SvetoslavTsenov Test this and let's merge it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants